﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ExtendPropertyLib;
using ExtendPropertyLib.WPF;
using ExORMDesginer.UserControls.Dialogs;
using ExORMDesginer.Models;
using ExORMDesginer.Helper;
using ExORMDesginer.RadWindow.Helper;
using ExORMDesginer.Plugin;


namespace WPFCanvas.CustomControls
{
    /// <summary>
    /// Interaction logic for QueryNodeView.xaml
    /// </summary>
    public partial class QueryNodeView : UserControl, INodeView
    {
        public QueryNodeView()
        {
            InitializeComponent();
        }

        public void GetInfoformation()
        {
            var data = this.DataContext as DbEntity;
            EntityInfomationDialogInfo info = new EntityInfomationDialogInfo() { Info = data };
            info.OnDoCreate(info,null);
            var viewModel = ViewModelFactory.GetModel<EntityInfomationDialogViewModel>(info);
            var wm = new RadWindowManager();
            wm.ShowDialog(viewModel);

        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
             var data = this.DataContext as DbEntity;
             if (data.EntityViewType == EntityType.StoredProcedure)
             {
                 border.BorderBrush = Brushes.Yellow;
                 title.Foreground = Brushes.Yellow;
                 this.ToolTip = "类型：存储过程 - " + data.DisplayName;
             }
             else if (data.EntityViewType == EntityType.View)
             {
                 border.BorderBrush = Brushes.DeepPink;
                 title.Foreground = Brushes.DeepPink;
                 this.ToolTip = "类型：视图 - " + data.DisplayName;
             }
             else
             {
                 this.ToolTip = "类型：表 - " + data.DisplayName;
             }
        }
    }
}
